//
//  ActivityDetailView.m
//  豆瓣(阿黄)
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ActivityDetailView.h"

@implementation ActivityDetailView

-(instancetype)initWithFrame:(CGRect)frame{

    [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{

    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 20, 300, 40)];
//    self.titleLabel.backgroundColor = [UIColor grayColor];
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    [self addSubview:self.titleLabel];
    [self.titleLabel release];
    
    self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(25, 70, 120, 150)];
//    self.picImageView.backgroundColor = [UIColor grayColor];
    [self addSubview:self.picImageView];
    [self.picImageView release];
    
    self.timeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(155, 75, 20, 20)];
    self.timeImageView.image = [UIImage imageNamed:@"icon_date_blue@2x.png"];
    [self addSubview:self.timeImageView];
    [self.timeImageView release];
    
    self.sponsorImageView = [[UIImageView alloc] initWithFrame:CGRectMake(155, 105, 20, 20)];
    self.sponsorImageView.image = [UIImage imageNamed:@"icon_sponsor_blue@2x.png"];
    [self addSubview:self.sponsorImageView];
    [self.sponsorImageView release];
    
    self.typeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(155, 135, 20, 20)];
    self.typeImageView.image = [UIImage imageNamed:@"icon_catalog_blue@2x.png"];
    [self addSubview:self.typeImageView];
    [self.typeImageView release];
    
    self.addressImageView = [[UIImageView alloc] initWithFrame:CGRectMake(155, 165, 20, 20)];
    self.addressImageView.image = [UIImage imageNamed:@"icon_spot_blue@2x.png"];
    [self addSubview:self.addressImageView];
    [self.addressImageView release];
    
    self.introduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, 220, 90, 40)];
    self.introduceLabel.text = @"活动介绍";
    self.introduceLabel.font = [UIFont boldSystemFontOfSize:20];
    [self addSubview:self.introduceLabel];
    [self.introduceLabel release];
    
    self.timeLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(185, 75, 100, 20)];
//    self.timeLabel1.backgroundColor = [UIColor grayColor];
    self.timeLabel1.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.timeLabel1];
    [self.timeLabel1 release];
    
    self.timeLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(280, 75, 100, 20)];
//    self.timeLabel2.backgroundColor = [UIColor grayColor];
    self.timeLabel2.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.timeLabel2];
    [self.timeLabel2 release];
    
    self.sponsorLabel = [[UILabel alloc] initWithFrame:CGRectMake(185, 105, 170, 20)];
//    self.sponsorLabel.backgroundColor = [UIColor grayColor];
    self.sponsorLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.sponsorLabel];
    [self.sponsorLabel release];
    
    self.typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(185, 135, 170, 20)];
//    self.typeLabel.backgroundColor = [UIColor grayColor];
    self.typeLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.typeLabel];
    [self.typeLabel release];
    
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(185, 165, 170, 60)];
//    self.addressLabel.backgroundColor = [UIColor grayColor];
    self.addressLabel.numberOfLines = 0;
    self.addressLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.addressLabel];
    [self.addressLabel release];
    
    self.content = [[UILabel alloc] initWithFrame:CGRectMake(25, 270, 330, 300)];
    self.content.numberOfLines = 0;
    self.content.font = [UIFont systemFontOfSize:17];
//    self.content.backgroundColor = [UIColor grayColor];
    [self addSubview:self.content];
    [self.content release];
    
}

#pragma mark -- 计算内容高度第一步:封装算法
+ (CGFloat)heightForContent:(NSString *)content{
    
    //参数1.设置计算高度按照什么样的size来计算
    //宽度一定与lable宽度一致,高度尽量大些
    //参数2.设置计算类型
    //参数3.设置计算内容按照多大的字体计算
    //注意:字体大小也要跟label字体一样
    //参数4.系统备用参数,设置为nil
    CGSize size = CGSizeMake(330, 10000);
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
                         [UIFont systemFontOfSize:17.0], NSFontAttributeName, nil];
    CGRect frame = [content boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return frame.size.height;
}


@end
